var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        tabIndex: 0,
        tabArray: [ {
            name: "全部"
        }, {
            name: "已结算"
        }, {
            name: "未结算"
        }, {
            name: "无效"
        } ],
        startTimeText: "",
        endTimeText: "",
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        networkLoading: !1,
        details: {},
        sid: 0,
        shop_type: 0
    },
    setShopType: function(t) {
        var a = t.currentTarget.dataset.index;
        a != this.data.shop_type && (this.setData({
            shop_type: a
        }), this.getListData());
    },
    setTabIndex: function(t) {
        var a = t.currentTarget.dataset.index;
        a != this.data.tabIndex && (this.setData({
            tabIndex: a
        }), this.getListData());
    },
    handRecord: function(t) {
        var a = t.currentTarget.dataset.id;
        a != this.data.sid ? this.setData({
            sid: a
        }) : this.setData({
            sid: 0
        });
    },
    bindDateChange: function(a) {
        var e = a.currentTarget.dataset.type, s = a.detail.value;
        if (!("start" == e && this.data.startTimeText == s || "end" == e && this.data.endTimeText == s)) {
            var i = "startTimeText";
            "end" == e && (i = "endTimeText"), this.setData(t({}, i, s)), "" != this.data.startTimeText && "" != this.data.endTimeText && this.getListData();
        }
    },
    initPage: function() {
        this.setData({
            listData: [],
            networkLoading: !1
        }), this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0;
    },
    getListData: function() {
        var t = this;
        this.initPage();
        var e = a.getNetAddresss("plugin.owner-order-import.frontend.controllers.page.index"), s = {};
        "" != this.data.startTimeText && "" != this.data.endTimeText && (s.start = parseInt(new Date(this.data.startTimeText.replace(/-/g, "/")).getTime() / 1e3), 
        s.end = parseInt(new Date(this.data.endTimeText.replace(/-/g, "/")).getTime() / 1e3)), 
        1 == this.data.tabIndex && (s.status = 2), 2 == this.data.tabIndex && (s.status = 1), 
        3 == this.data.tabIndex && (s.status = -1), s.shop_type = this.data.shop_type, a._getNetWork({
            url: e,
            data: s,
            success: function(e) {
                var s = e.data;
                if (1 != s.result) return a.tips(s.msg);
                1 != s.data.info.need_perfect ? (t.setData({
                    isLoadMore: !0,
                    total_page: s.data.page_list.last_page,
                    listData: s.data.page_list.data,
                    details: s.data.info,
                    networkLoading: !0
                }), t.data.total_page || (t.data.total_page = 0)) : wx.showModal({
                    content: "请完善店主信息",
                    showCancel: !1,
                    success: function(t) {
                        t.confirm && wx.navigateTo({
                            url: "/packageH/orderImport/orderImportApply/orderImportApply?shopkeeper=1"
                        });
                    }
                });
            }
        });
    },
    getMoreData: function() {
        var t = this, e = a.getNetAddresss("plugin.owner-order-import.frontend.controllers.page.index");
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page++;
            var s = {
                page: this.data.page
            };
            "" != this.data.startTimeText && "" != this.data.endTimeText && (s.start = parseInt(new Date(this.data.startTimeText.replace(/-/g, "/")).getTime() / 1e3), 
            s.end = parseInt(new Date(this.data.endTimeText.replace(/-/g, "/")).getTime() / 1e3)), 
            1 == this.data.tabIndex && (s.status = 2), 2 == this.data.tabIndex && (s.status = 1), 
            3 == this.data.tabIndex && (s.status = -1), s.shop_type = this.data.shop_type, a._getNetWork({
                url: e,
                data: s,
                success: function(a) {
                    var e = a.data;
                    if (1 == e.result) {
                        t.data.isLoadMore = !0;
                        var s = e.data.page_list.data;
                        t.setData({
                            listData: t.data.listData.concat(s)
                        });
                    } else t.data.isLoadMore = !1, t.data.page--;
                }
            });
        }
    },
    onLoad: function(t) {
        this.getListData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});